#region (c)2008 Lokad - New BSD license

// Copyright (c) Lokad 2008 
// Company: http://www.lokad.com
// This code is released under the terms of the new BSD licence

#endregion

using System;
using System.IO;
using System.Reflection;
using log4net;
using log4net.Config;
using Photon.Logging;
using ILog=System.Logging.ILog;

namespace Photon
{
	///<summary>
	/// This class provides hookup routines to the logging library
	/// For the logical consistency, it should be used
	/// by application entry points only
	///</summary>
	public static class LoggingUtil
	{
		/// <summary>
		/// Configures the logging system to write to console
		/// </summary>
		public static void UseConsole()
		{
			BasicConfigurator.Configure();
		}

		/// <summary>
		/// Logging system is configured from App.config
		/// </summary>
		public static void UseConfig()
		{
			XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetEntryAssembly()));
		}

		/// <summary>
		/// File is used to configure the logging system
		/// </summary>
		/// <param name="fileName"></param>
		public static void ConfigureFromFile(string fileName)
		{
			XmlConfigurator.Configure(new FileInfo(fileName));
		}

		/// <summary>
		/// Get log provider
		/// </summary>
		/// <returns></returns>
		public static INamedProvider<ILog> GetLogProvider()
		{
			return LogProviderWrapper.Instance;
		}

	}
}